const { getStoreConfig, getThemes } = require('../service/requestAdmin');
var { shop, theme } = require('../config');

module.exports = async function (ctx, next) {
  if (shop.TOKEN) {
    const list = await getThemes();
    const defaultTheme = list.find((item) => item.default);
    if (defaultTheme) {
      theme.setTemplateId(defaultTheme.id);
      theme.setTheme(defaultTheme.name);
    } else {
      console.log('请设置默认主题');
    }
  } else {
    console.log('请设置shop.TOKEN');
  }
};
